package roaringimport// Values returns an iterator that yields the elements of the bitmap in// increasing order. Starting with Go 1.23, users can use a for loop to iterate// over it.func ( *Bitmap) iter.Seq[uint32] {returnfunc( func(uint32) bool) { := .Iterator()for .HasNext() {if !(.Next()) {return } } }}// Backward returns an iterator that yields the elements of the bitmap in// decreasing order. Starting with Go 1.23, users can use a for loop to iterate// over it.func ( *Bitmap) iter.Seq[uint32] {returnfunc( func(uint32) bool) { := .ReverseIterator()for .HasNext() {if !(.Next()) {return } } }}// Unset creates an iterator that yields values in the range [min, max] that are NOT contained in the bitmap.// The iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).func ( *Bitmap, , uint32) iter.Seq[uint32] {returnfunc( func(uint32) bool) { := .UnsetIterator(uint64(), uint64()+1)for .HasNext() {if !(.Next()) {return } } }}// Ranges iterates contiguous ranges of values present in the bitmap as// half-open [start, endExclusive) pairs. endExclusive is uint64 to represent// ranges that include MaxUint32. Ranges spanning container boundaries are merged.func ( *Bitmap) () iter.Seq2[uint32, uint64] {returnfunc( func(uint32, uint64) bool) { := &.highlowcontainer := .keys := .containers := len()var , uint64 := false := func(, uint64) bool {if && <= {if > { = }returntrue }if {if !(uint32(), ) {returnfalse } } = = = truereturntrue }for := 0; < ; ++ { := uint64([]) << 16 := []switch t := .(type) {case *runContainer16:for , := range .iv {if !(+uint64(.start), +uint64(.start)+uint64(.length)+1) {return } }case *bitmapContainer: := .bitmap := uint(len()) := uint(0)for < { := []if == 0 { ++continue }for != 0 { := uint(countTrailingZeros()) := *64 + := uint(countTrailingOnes( >> ))if + < 64 {if !(+uint64(), +uint64(+)) {return } &= ^((uint64(1) << ( + )) - 1) } else { ++for < && [] == 0xFFFFFFFFFFFFFFFF { ++ }varuintif < { := uint(countTrailingOnes([])) = *64 + = [] & ^((uint64(1) << ) - 1) } else { = * 64 = 0 }if !(+uint64(), +uint64()) {return }continue } } ++ }case *arrayContainer: := .content := 0for < len() { := uint64([]) := + 1 ++for < len() && uint64([]) == { ++ ++ }if !(+, +) {return } } } }if { (uint32(), ) } }}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.